#pragma once

#ifndef _TreePlanter_h_
#define _TreePlanter_h_

#include <vector>
#include "Terrain.h"
#include "Tree.h"
#include "../../Framework/Octree.h"

namespace MyGame {

using namespace Framework;
using namespace std;

class Terrain;

class TreePlanter :
            public DrawableGameComponent {
public:
    TreePlanter(Game* game);
    virtual ~TreePlanter(void);
    FLOAT GetLodRange() const;
    void SetLodRange(FLOAT val);
    FLOAT GetVisibilityRange() const;
    void SetVisibilityRange(FLOAT val);
    void SetTerrain(Terrain* val);
    void SetTreeLineHeights(FLOAT minHeight, FLOAT treeLine1Height, FLOAT treeLine2Height, FLOAT treeLine3Height);
    virtual void Draw(FLOAT timeDelta);
    virtual void Initialize();
    virtual void LoadContent();
    virtual void UpdateVisibleParts();
private:
    FLOAT lodRange;
    FLOAT minHeight;
    Octree<vector<Tree*>*>* octree;
    Terrain* terrain;
    FLOAT treeLine1Height;
    FLOAT treeLine2Height;
    FLOAT treeLine3Height;
    LPCSTR* treeModels;
    LPCSTR* treeModelsLOD;
    vector<TreeBase<vector<Tree*>*>*>* visibleTrees;
    FLOAT visibilityRange;
    void InitializeOctree(Octree<vector<Tree*>*>* octree);
    void Insert(Octree<vector<Tree*>*>* octree, Tree* tree, D3DXVECTOR3 position);
};

}

#endif
